<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<head>
<%@include file="/fragment/header.jsp"%>
<script language="javascript">
	function changeAction(url) {
		var f = document.getElementById("workLogMaintainForm");
		f.action = url;
		return true;
	}
	function openLov() {
		window
				.open(
						'${pageContext.request.contextPath}/workLog/initPickWbs.do',
						'LOL',
						'scrollbars=yes,height=400px,width=600,status=yes,titlebar=yes',
						'Y')
	}
	$(function() {
		$("#qryStartDate").datepicker({
			dateFormat : 'yy/mm/dd',
		});
	});

	$(function() {
		$("#qryEndDate").datepicker({
			dateFormat : 'yy/mm/dd'
		});
	});
	$(function() {
		$("#editWorkDate").datepicker({
			dateFormat : 'yy/mm/dd'
		});
	});
	function preEditRecord(workLogSn, wbsSn, workDate, wbsName, hr,
			workLogContent) {
		$("#editWorkLogSn").val(workLogSn);
		$("#editWbsSn").val(wbsSn);
		$("#editWorkDate").val(workDate);
		$("#editWbsName").val(wbsName);
		$("#editHr").val(hr);
		$("#editWorkLogContent").val(workLogContent);

	}
</script>
</head>
<body>
    <div id="container">
        <div id="header">
            歡迎, ${user.userName}, <a href="${pageContext.request.contextPath}/logout.do">登出</a>
        </div>
        <%@include file="/fragment/menu.jsp"%>
        你在這&gt;&gt;工作日誌
        <div id="info_msg">
            訊息: <span class="info_msg">${msg}</span>
        </div>
        <form:form id="workLogMaintainForm" commandName="workLogMaintainForm"
            action="${pageContext.request.contextPath }/workLog/maintainWorkLog.do" autocomplete="off"
        >
            <fieldset>
                <legend class="section_title">查詢</legend>
                日期:
                <form:input path="searchStartDate" id="searchStartDate" size="10" value="${deftQryStartDate}" />
                -
                <form:input path="searchEndDate" id="searchEndDate" size="10" value="${deftQryEndDte}" />
                人員:
                <form:select path="searchWorker">
                    <form:option value="">請選擇</form:option>
                    <form:options items="${sysUsers}" />
                </form:select>
                <button type="submit" class="btn" name="searchWorkLog" value="SEARCH_WORK_LOG">查詢</button>
            </fieldset>
            <fieldset>
                <legend class="section_title">修改</legend>
                工作日:
                <form:hidden path="editWorkLogSn" />
                <form:input path="editWorkDate" size="10" id="editWorkDate" />
                任務:
                <form:hidden path="editWbsSn" id="editWbsSn" />
                <form:input path="editWbsName" id="editWbsName" readonly="true" />
                <button type="button" onclick="openLov(this)" class="btn">瀏覽</button>
                工時:
                <form:input path="editHr" size="2" />
                其他說明:
                <form:input path="editWorkLogContent" />
                <label for="select">人員:</label>
                <form:select path="editWorker">
                    <form:options items="${sysUsers}" />
                </form:select>
                <br>
                <!-- 
                <button type="submit" class="btn"
                    onclick="return changeAction('${pageContext.request.contextPath}/workLog/addWorkLog.do')"
                >新增</button>
                 -->
                <form:button name="addWorkLog" class="btn" value="addWorkLog">新增</form:button>
                <!-- Name與Value要不一樣 -->
                <form:button name="modifyWorkLog" class="btn" value="modifyWorkLog">修改</form:button>
                <button type="reset" id="clearWorkLog" name="clearWorkLog" value="clearWorkLog" class="btn"
                    title="恢復到上次提效的狀況"
                >清除</button>
                <form:button name="delWorkLog" class="btn" value="delWorkLog">刪除</form:button>
            </fieldset>
            <table style="width: 100%" border="1">
                <tr>
                    <td>刪除</td>
                    <td>日期</td>
                    <td>人員</td>
                    <td>專案</td>
                    <td>任務</td>
                    <td>類型</td>
                    <td>時數</td>
                    <td>說明</td>
                </tr>

                <c:forEach items="${workLogVvoList}" var="data">
                    <tr>
                        <td><input type="radio" name="editdRecord" value="${ data.workLogSn}"
                                onclick="return preEditRecord('${ data.workLogSn}', '${data.wbsSn}','${data.workDateStr }','${data.wbsName }','${data.hr }','${data.workLogContent }');"
                            ></td>
                        <td>${data.workDateStr }</td>
                        <td>${data.worker }</td>
                        <td>${data.projName }</td>
                        <td>${data.wbsName }</td>
                        <td>${data.wbsTypeDscr }</td>
                        <td>${data.hr }</td>
                        <td>${data.workLogContent }</td>
                    </tr>
                </c:forEach>
            </table>
        </form:form>
        <div id="footer">
            <%@include file="/fragment/footer.jsp"%>
        </div>
    </div>
</body>
</html>
